﻿using System;
using System.Collections.Generic;
using System.Text;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.UI.Security.Services;

namespace Sinacor.UI.Bovespa.Operador.Communication
{
    public class Negocio : BaseCommunication
    {
        #region Construtor
        public Negocio(SessionInformation sessionInformation) : base(sessionInformation) { }
        #endregion

        #region ConsultarBolsas
        public ModelCollection<Model.Bolsa> ConsultarBolsas()
        {
            Bovespa.Ordens.Negocio.INegocio servico = null;
            ModelCollection<Model.Bolsa> retorno = null;

            try
            {
                using (ServiceInstance<Bovespa.Ordens.Negocio.INegocio> serviceManager = new ServiceInstance<Bovespa.Ordens.Negocio.INegocio>())
                {
                    servico = serviceManager.TryGetInstance(this.Session);
                    retorno = new Translator.DataContractToModel.Negocio().ToBolsa(servico.ConsultarBolsas());
                }
            }
            catch (Exception ex)
            {
                base.HandleFault(ex);
            }

            return retorno;
        }

        #endregion
    }
}
